package cc.vv.baselibrary.util.user_info

import cc.vv.lkbasecomponent.util.LKSPUtil

/**
 *
 * @author Zml
 * @date 2018/7/23.
 */

class UserManager private constructor() {

    private object Holder {
        val INSTANCE = UserManager()
    }

    companion object {
        val instance: UserManager by lazy { Holder.INSTANCE }
    }

    public fun saveUserInfo(user: UserInfo) {
        saveUserId(user.id)
        saveAccount(user.account)
        saveToken(user.token)
    }

    public fun getUserId(): String {
        return LKSPUtil.getInstance().getString("sp_userId", "");
    }

    public fun saveUserId(userId: String?) {
        LKSPUtil.getInstance().put("sp_userId", userId!!)
    }

    public fun getAccount(): String {
        return LKSPUtil.getInstance().getString("sp_account", "");
    }

    public fun saveAccount(account: String?) {
        LKSPUtil.getInstance().put("sp_account", account!!)
    }

    public fun getToken(): String {
        return LKSPUtil.getInstance().getString("sp_token", "");
    }

    public fun saveToken(token: String?) {
        LKSPUtil.getInstance().put("sp_token", token!!)
    }
}